﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTO;
using System.Data;
using System.Data.OleDb;

namespace DAO
{
    public  class PhongDAO
    {
        DataTable dt = new DataTable();
        OleDbDataAdapter da = new OleDbDataAdapter();
        public DataTable LoadDanhSachPhongDAO()
        {
            OleDbConnection cn = DataProvider.ConectDatabase();
            da = new OleDbDataAdapter(DataProvider.ExecProduce("DanhSachPhong", cn));
            da.Fill(dt);
            cn.Close();
            return dt;
        }
        public DataTable LayThongTinPhong(int id)
        {

            DataTable thongtin = new DataTable();
            OleDbConnection cn = DataProvider.ConectDatabase();
            thongtin = DataProvider.DataTableQueryParameters("LayThongTinPhong","@MaPhong",id);
            cn.Close();
            return thongtin;
        }
        public  void UpdateTinhTrangPhong(int maphong,int tinhtrang)
        {
            OleDbCommand cmd = DataProvider.CreateCommand("UpdateTinhTrangPhong", "@MaTinhTrang", tinhtrang, "@MaPhong", maphong);
            cmd.Connection.Open();
            cmd.ExecuteNonQuery();
            cmd.Connection.Close();
            
            
        }

        public DataTable LoadDanhSachPhongTheoTinhTrang(int tinhtrang)
        {
            return DataProvider.LoadTable("Select * from Phong Where MaTinhTrang="+tinhtrang);
        }
        
    }
}
